package br.affero.web.controller;

import java.io.Serializable;

import javax.enterprise.inject.Produces;
import javax.faces.bean.ViewScoped;
import javax.inject.Named;

import br.affero.core.person.model.Person;

@Named("personHome")
@ViewScoped
public class PersonHome extends EntityHome<Person> implements Serializable {
	private static final long serialVersionUID = 1817377469468114301L;
	
	protected Integer personId;
	

	
	public Person getInstance()
	{
		Person person = (Person) super.getInstance();
		
		
		return person;
	}
	
	
	
	/**
	 * {@inheritDoc}
	 * 
	 * @see org.jboss.seam.framework.Home#getId() 
	 */
	public Object getId()
	{
		if (personId == null)
		{
			return super.getId();
		}
		else
		{
			return personId;
		}
	}
	
	public void setPersonId(Integer id) {
		this.personId = id;
	}
	
	public Integer getPersonId() {
		return this.personId;
	}
	
	
	/**
	 * Factory de instâncias de Persons 
	 * 
	 * @return Instância de uma Person.
	 */
	@Produces
	@Named("person")
	public Person initPerson()
	{
		return getInstance();
	}
	
	
}
